package com.kcbsdk;

import android.util.Log;

import com.kcbsdk.MyDevice.AAmplifyWork;
import com.kcbsdk.MyDevice.AAudioWork;
import com.kcbsdk.MyDevice.ABindInfo;
import com.kcbsdk.MyDevice.ADeviceInfo;
import com.kcbsdk.MyDevice.AMediaWork;
import com.kcbsdk.MyDevice.ARdWrFileStatus;
import com.kcbsdk.MyDevice.AShareAdmin;
import com.kcbsdk.MyDevice.ASysRegister;
import com.kcbsdk.MyDevice.AWifiList;

public class CSvrDevice implements wpapper {
    public int g4EventMethod;

    public int pollingEvent(int devNum){
        return g4EventMethod | cjmkcs.systemPollingEvent(tDEVICE, devNum);
    }
    public void setMethodType(){
//	MSTRING("setMethodType");
        cjmkcs.systemSetMethodType(tDEVICE | 0x00000001);
    }
    public int getMethodType(){
        return cjmkcs.systemSetMethodType(tDEVICE);
    }
    public String getMethodMessage(int type){
        return cjmkcs.systemGetMethodMessage(type);
    }
    public int setDevInfoDbs(int devNum, int type, String macAddr){
//        MSTRING(String.format("setDevInfoDbs %d %d %s", devNum, type, macAddr));
        if (null != macAddr) {
            return cjmkcs.deviceSetDevInfoDbs(devNum, type, macAddr, DEVICE_SET_DBS_DEV_INFO);
        }
        return 0;
    }
    public void FindDevInfo(int type, int remPort, String domainName, String password){
        if (null != domainName && null != password) {
            cjmkcs.deviceFindDevInfo(type, remPort, domainName, password, DEVICE_GET_DEV_INFO_LIST);
        }
    }
    public void cancelAndRestart(int devNum, int local, int remote){
        cjmkcs.deviceCancelRestart(devNum, local, remote);
    }
    public void fetchWifiList(int devNum){
        cjmkcs.deviceFetchWifiList(devNum, DEVICE_GET_WIFI_LIST);
    }
    public void modifyWifi(int devNum, String wifiName, String password){
        if (null != wifiName && null != password) {
            cjmkcs.deviceModifyWifi(devNum, wifiName, password, DEVICE_MODIFY_WIFI);
        }
    }
    public void readBulkFile(int devNum, int type, int addrss, int length, String fileName){
        if (null != fileName) {
            cjmkcs.deviceReadBulkFile(devNum, type,addrss,length, fileName, DEVICE_READ_FILE);
        }
    }
    public void writeBulkFile(int devNum, int type, int addrss, int length, String fileName){
        if (null != fileName) {
            cjmkcs.deviceWriteBulkFile(devNum, type,addrss,length, fileName, DEVICE_WRITE_FILE);
        }
    }
    public void debugControl(int devNum, int debugUser, int layout, int mode, String path){
        if (null != path) {
            cjmkcs.deviceDebugControl(devNum, debugUser, layout, mode, path, DEVICE_DEBUG_CONTROL | ((debugUser << 8) | layout));
        }
    }
    public void writeRtcText(int devNum, int code, String text){
        if (null != text) {
            cjmkcs.deviceWriteRtcText(devNum, code, text, DEVICE_WR_RTC_TEXT);
        }
    }
    public void ctrlRemoteKey(int devNum, int key){
        cjmkcs.deviceCtrlRemoteKey(devNum, key, DEVICE_REMOTE_KEY);
    }
    public void playTrack(int devNum, int userID, int fileID){
        cjmkcs.devicePlayTrack(devNum, userID, fileID, DEVICE_PLAY_TRACK);
    }
    public void modifyDevInfo(int devNum, ADeviceInfo aDeviceInfo){
        String mixInfo;
        int flag0 = 0;
        if (aDeviceInfo.isDhcpOn){
            flag0 |= 0x01;
        }
        if (aDeviceInfo.isGenerateWifi){
            flag0 |= 0x02;
        }
        int flag1 = (aDeviceInfo.ProductType & 0xff) | ((aDeviceInfo.ProductSub & 0xff) << 8);
        // (0)调试端口(1)从机IP(2)掩码(3)网关(4)DNS(5)域名(6)解析密码(7)牌子(8)型号(9)昵称(10)发射WIFI名
        mixInfo = aDeviceInfo.DebugPort + ",";
        mixInfo += aDeviceInfo.IPAddress + ",";
        mixInfo += aDeviceInfo.NetMask + ",";
        mixInfo += aDeviceInfo.GateWay + ",";
        mixInfo += aDeviceInfo.DnsServer + ",";
        mixInfo += aDeviceInfo.DomainName + ",";
        mixInfo += aDeviceInfo.DomainPsw + ",";
        mixInfo += aDeviceInfo.ProductBrand + ",";
        mixInfo += aDeviceInfo.ProductModel + ",";
        mixInfo += aDeviceInfo.NickName + ",";
        mixInfo += aDeviceInfo.GenWifiName + ",";
        cjmkcs.deviceModifyDevInfo(devNum, flag0, flag1, mixInfo, DEVICE_MODIFY_DEV_INFO);
    }
    public void fetchBindInfo(int devNum){
        cjmkcs.deviceFetchBindInfo(devNum, DEVICE_FETCH_BIND_INFO);
    }
    public void modifyBindInfo(int devNum, int amount, ABindInfo aBindInfo[]){
        String mixInfo = "";
        String gsLocal_1;
        for (int counter = 0; counter < amount; counter++){
            gsLocal_1 = String.format("%d,", aBindInfo[counter].ProductType);
            mixInfo = gsLocal_1;
            gsLocal_1 = String.format("%d,", aBindInfo[counter].aAudioChannel);
            mixInfo += gsLocal_1;
            mixInfo += aBindInfo[counter].DomainName + ",";
            mixInfo += aBindInfo[counter].DomainPassword + ",";
        }
        cjmkcs.deviceModifyBindInfo(devNum, amount, mixInfo, DEVICE_MODIFY_BIND_INFO);
    }
    public void fetchShareAdmin(int devNum){
        cjmkcs.deviceFetchShareAdmin(devNum, DEVICE_FETCH_SHARE_ADMIN);
    }
    public void modifyShareAdmin(int devNum, int amount, AShareAdmin aShareAdmin[]){
        String mix = "";
        cjmkcs.deviceModifyShareAdmin(devNum, amount, mix, DEVICE_FETCH_SHARE_ADMIN);
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public ADeviceInfo[] eventDbsDevInfo(int devNum, int event){
        cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_DBS_DEV_INFO, devNum & 0xff);
        int retSize = cjmkcs.systemGetWpapperValue(wpDEVICE_DbsDevInfoQty);
        ADeviceInfo aADeviceInfo[] = new ADeviceInfo[retSize];
        for (int counter = 0; counter < retSize; counter++){	// counter为devNum
            getDevInfoDetail(wpDEVICE_DbsDevInfoStr | counter, counter, aADeviceInfo);
        };
        g4EventMethod |= DEVICE_EVENT_DBS_DEV_INFO;
        return aADeviceInfo;
    }
    public ADeviceInfo[] eventFindDevInfo(int event){	// 读取Find不需要devNum
        cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_FIND_DEV_INFO, 0);
        int retSize = cjmkcs.systemGetWpapperValue(wpDEVICE_FindDevInfoQty);
        ADeviceInfo aADeviceInfo[] = new ADeviceInfo[retSize];
        for (int counter = 0; counter < retSize; counter++){
            getDevInfoDetail(wpDEVICE_FindDevInfoStr | (counter << 8), counter, aADeviceInfo);
//System.out.println("isEventFindDevInfo");System.out.println(aADeviceInfo[counter]);
        };
//MDEBUG(0x19);MDEBUG(retSize);MSTRING(aADeviceInfo[counter].NickName);
        g4EventMethod |= DEVICE_EVENT_FIND_DEV_INFO;
        return aADeviceInfo;
    }
    public AWifiList[] eventWifiList(int devNum, int event){
        cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_WIFI_LIST, devNum & 0xff);
        int retSize = cjmkcs.systemGetWpapperValue(wpDEVICE_WifiListQty | (devNum & 0xff));
        AWifiList aWifiList[] = new AWifiList[retSize];
//MSTRING("isEventWifiList "+retSize[0] + " "+devNum );
        int g4Local_1;
        for (int counter = 0; counter < retSize; counter++){
            aWifiList[counter] = new AWifiList();
            g4Local_1 = (counter << 8) | (devNum & 0xff);
            aWifiList[counter].MacAddress  = cjmkcs.systemGetWpapperString(wpDEVICE_WifiMacAddress | g4Local_1);
            aWifiList[counter].Authmode = cjmkcs.systemGetWpapperString(wpDEVICE_WifiAuthMode | g4Local_1);
            aWifiList[counter].Rssi = cjmkcs.systemGetWpapperString(wpDEVICE_WifiRssi | g4Local_1);
            aWifiList[counter].Channel  = cjmkcs.systemGetWpapperString(wpDEVICE_WifiChannel | g4Local_1);
            aWifiList[counter].Hidden  = cjmkcs.systemGetWpapperString(wpDEVICE_WifiIsHidden| g4Local_1);
            aWifiList[counter].WifiName  = cjmkcs.systemGetWpapperString(wpDEVICE_WifiName | g4Local_1);
            aWifiList[counter].WifiPsw  = cjmkcs.systemGetWpapperString(wpDEVICE_WifiPsw | g4Local_1);
        };
        g4EventMethod |= DEVICE_EVENT_WIFI_LIST;
        return aWifiList;
    }
    public int eventLinkMode(int devNum, int event){
        cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_LINK_MODE, devNum & 0xff);
        int linkMode = cjmkcs.systemGetWpapperValue(wpDEVICE_LinkMode | (devNum & 0xff));
        g4EventMethod |= DEVICE_EVENT_LINK_MODE;
        return linkMode;
    }
    public String eventDebugText(int devNum, int event){
        cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_DEBUG_TEXT, devNum & 0xff);
        String tect = cjmkcs.systemGetWpapperString(wpDEVICE_DebugText | (devNum & 0xff));
        g4EventMethod |= DEVICE_EVENT_DEBUG_TEXT;
        return tect;
    }
    public ARdWrFileStatus eventReadFile(int devNum, int event){
        cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_RD_FILE, devNum & 0xff);
        ARdWrFileStatus aRdWrFileStatus = new ARdWrFileStatus();
        aRdWrFileStatus.Length = cjmkcs.systemGetWpapperValue(wpDEVICE_ReadFile + (0 << 8) | (devNum & 0xff));
        aRdWrFileStatus.Counter = cjmkcs.systemGetWpapperValue(wpDEVICE_ReadFile + (1 << 8) | (devNum & 0xff));
        aRdWrFileStatus.Done = cjmkcs.systemGetWpapperValue(wpDEVICE_ReadFile + (2 << 8) | (devNum & 0xff));
        aRdWrFileStatus.Result = cjmkcs.systemGetWpapperString(wpDEVICE_ReadFile + (3 << 8) | (devNum & 0xff));
        g4EventMethod |= DEVICE_EVENT_RD_FILE;
        return aRdWrFileStatus;
    }
    public ARdWrFileStatus eventWriteFile(int devNum, int event){
        cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_WR_FILE, devNum & 0xff);
        ARdWrFileStatus aRdWrFileStatus = new ARdWrFileStatus();
        aRdWrFileStatus.Length = cjmkcs.systemGetWpapperValue(wpDEVICE_WriteFile + (0 << 8) | (devNum & 0xff));
        aRdWrFileStatus.Counter = cjmkcs.systemGetWpapperValue(wpDEVICE_WriteFile + (1 << 8) | (devNum & 0xff));
        aRdWrFileStatus.Done = cjmkcs.systemGetWpapperValue(wpDEVICE_WriteFile + (2 << 8) | (devNum & 0xff));
        aRdWrFileStatus.Result = cjmkcs.systemGetWpapperString(wpDEVICE_WriteFile + (3 << 8) | (devNum & 0xff));
//MSTRING(cjmkcs.systemGetWpapperString(wpDEVICE_WriteFile + 3));
        g4EventMethod |= DEVICE_EVENT_WR_FILE;
        return aRdWrFileStatus;
    }
    public String eventRtcText(int devNum, int event){
        cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_RTC_TEXT, devNum & 0xff);
        String text = cjmkcs.systemGetWpapperString(wpDEVICE_RtcText | (devNum & 0xff));
        g4EventMethod |= DEVICE_EVENT_RTC_TEXT;
        return text;
    }
    public ABindInfo[] eventBindInfo(int devNum, int event){
        cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_BIND_INFO, devNum & 0xff);
        int retSize = cjmkcs.systemGetWpapperValue(wpDEVICE_BindInfoSize | (devNum & 0xff));
        ABindInfo aBindInfo[] = new ABindInfo[retSize];
        int g4Local_1;
        for (int counter = 0; counter < retSize; counter++){
            aBindInfo[counter] = new ABindInfo();
            g4Local_1 = (counter << 8) | devNum;
            aBindInfo[counter].DomainName = cjmkcs.systemGetWpapperString(wpDEVICE_BindInfoName | g4Local_1);
            aBindInfo[counter].DomainPassword = cjmkcs.systemGetWpapperString(wpDEVICE_BindInfoPsw | g4Local_1);
            aBindInfo[counter].ProductType = cjmkcs.systemGetWpapperValue(wpDEVICE_BindInfoProduct | g4Local_1);
        //    aBindInfo[counter].aAudioChannel = (AAudioChannel)cjmkcs.systemGetWpapperValue(wpDEVICE_BindInfoChannel | g4Local_1);
        }
        g4EventMethod |= DEVICE_EVENT_BIND_INFO;
        return aBindInfo;
    }
    public AShareAdmin[] eventShareAdmin(int devNum, int event){
        cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_SHARE_ADMIN, devNum & 0xff);
        int retSize = cjmkcs.systemGetWpapperValue(wpDEVICE_ShareAdminSize | (devNum & 0xff));
        AShareAdmin aShareAdmin[] = new AShareAdmin[retSize];
        int g4Local_1;
        for (int counter = 0; counter < retSize; counter++){
            aShareAdmin[counter] = new AShareAdmin();
            g4Local_1 = (counter << 8) | devNum;
            aShareAdmin[counter].UserID = cjmkcs.systemGetWpapperString(wpDEVICE_ShareAdminKcid | g4Local_1);
            aShareAdmin[counter].Password = cjmkcs.systemGetWpapperString(wpDEVICE_ShareAdminPsw | g4Local_1);
        }
        g4EventMethod |= DEVICE_EVENT_SHARE_ADMIN;
        return aShareAdmin;
    }
//        if ((event & DEVICE_EVENT_LYRIC_TEXT) > 0){
//    public String eventLyricText(int devNum, int event, int retLine[]){
//        cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_LYRIC_TEXT, devNum & 0xff);
//        //retLine = cjmkcs.systemGetWpapperValue(wpDEVICE_LyricStrLine | (devNum & 0xff));
//        String text = cjmkcs.systemGetWpapperString(0 | devNum);
//        g4EventMethod |= DEVICE_EVENT_LYRIC_COLOR;
//        return text;
//    }
//    public boolean isEventLyricColor(int devNum, int event, int[] retline, int retSize[], byte colorPixel[]){
//        if ((event & DEVICE_EVENT_LYRIC_COLOR) > 0){
//            cjmkcs.systemClearEvent(tDEVICE, DEVICE_EVENT_LYRIC_COLOR, devNum & 0xff);
//            retline[0] = cjmkcs.systemGetWpapperValue(wpDEVICE_LyricColLine | (devNum & 0xff));
//            retSize[0] = cjmkcs.systemGetWpapperValue(wpDEVICE_LyricColLeng | (devNum & 0xff));
//            int g4Local_1;
//            int g4Local_2;
//            int g4Local_3 = 0;
//            int byteCounter;
//            for (int counter = 0; counter < retSize[0]; counter++){
////                colorPixel[counter] = new byte[512];
//                g4Local_1 = (counter << 8) | devNum;
//                g4Local_2 = cjmkcs.systemGetWpapperValue(wpDEVICE_LyricColor | devNum);
//                for (byteCounter = 0; byteCounter < 16; byteCounter++){
//                    colorPixel[g4Local_3++] = (byte)(g4Local_2 & 0x03);
//                    g4Local_2 >>= 2;
//                }
//            }
//            g4EventMethod |= DEVICE_EVENT_LYRIC_COLOR;
//            return true;
//        }
//        return false;
//    }
    public ASysRegister eventSysRegister(int devNum, int regNum, int g4Local_Buffer[]){
        if ((g4Local_Buffer[0] & 0x7f) >= (15 * 4)){
            ASysRegister aSysRegister = new ASysRegister();
            aSysRegister.AppRunBit = (g4Local_Buffer[1] & 0xff);		// 1#[7:6]最大使用寄存器[5:4][3:0]应用运行层面及地址

            aSysRegister.FunctionBit = ((g4Local_Buffer[1] >> 8) & 0xff);	// 1#产品功能标志
            aSysRegister.UserCpu = 200 + ((g4Local_Buffer[4] >> 24) & 0xff);	// 1#用户模块的型号

            aSysRegister.UserDate = g4Local_Buffer[2];		// 2#用户模块的固件日期
            aSysRegister.AppDate = g4Local_Buffer[3];		// 3#应用模块的固件日期
            aSysRegister.WifiCpu = 200 + (g4Local_Buffer[4] & 0xff);	// WIFI模块的型号

            aSysRegister.FixServerIP = g4Local_Buffer[4] & 0xffff;		// 4#主机IP地址类型  0x0000=不强制固定的IP地址(正常)
            aSysRegister.IPAddress = g4Local_Buffer[8];					// 8#产品网络地址
            aSysRegister.ServerIP = g4Local_Buffer[9];					// 9#产品连接服务器
            aSysRegister.FileServerIP = g4Local_Buffer[10];				// 10#产品连接文件服务器
            aSysRegister.OwnUserID = g4Local_Buffer[11];					// 11#域名主人的KCID

            aSysRegister.LanIPAddress = g4Local_Buffer[13];				// 13#当前内网地址
//	MDWORD(aSysRegister.LanIPAddress);
            aSysRegister.LanNetMask = g4Local_Buffer[14];					// 14#当前内网IP地址
            aSysRegister.LanGateWay = g4Local_Buffer[15];					// 15#当前内网掩码
            aSysRegister.WifiName = cjmkcs.systemGetWpapperString(wpDEVICE_RegCurrentWifi | (regNum << 14) | devNum);
            g4EventMethod |= 0x00010000;
            return aSysRegister;
        }
        return null;
    }
    public AAudioWork eventAudioWork(int devNum, int regNum, int g4Local_Buffer[]){
        AAudioWork aAudioWork = new AAudioWork();
        aAudioWork.MasterVolume = (g4Local_Buffer[1] & 0xff);	// 1#音响音量
        aAudioWork.InputSwitch = ((g4Local_Buffer[1] >> 8) & 0xff);	// 1#音响输入选择
        aAudioWork.ListenMode = ((g4Local_Buffer[1] >> 16) & 0xff);	// 1#音响聆听模式
        aAudioWork.InputFormat = ((g4Local_Buffer[1] >> 24) & 0xff);	// 1#音响输入信号格式

        int g4Local_1 = (g4Local_Buffer[2] & 0xff);	// 2#模式
        aAudioWork.isAC3NightMode = ((g4Local_1 & 0x04) > 0) ? true : false;
        aAudioWork.isPowerOn = ((g4Local_1 & 0x02) > 0) ? true : false;
        aAudioWork.isMuteAudio = ((g4Local_1 & 0x02) > 0) ? true : false;

        g4Local_1 = ((g4Local_Buffer[2] >> 8) & 0xff);	// 2#播放状态
        aAudioWork.isRepeatAll = ((g4Local_1 & 0x20) > 0) ? true : false;
        aAudioWork.isRepeatOne = ((g4Local_1 & 0x10) > 0) ? true : false;
        aAudioWork.isScanPlay = ((g4Local_1 & 0x08) > 0) ? true : false;
        aAudioWork.isRandomPlay = ((g4Local_1 & 0x04) > 0) ? true : false;
        aAudioWork.isPause = ((g4Local_1 & 0x02) > 0) ? true : false;
        aAudioWork.isPlaying = ((g4Local_1 & 0x01) > 0) ? true : false;
//MDEBUG(0xfd);MDWORD(g4Local_1);

        aAudioWork.PlayTime = ((g4Local_Buffer[2] >> 16) & 0xffff);		// 2#播放时间
        g4EventMethod |= 0x00020000;
        return aAudioWork;
    }
    public AMediaWork eventMediaWork(int devNum, int regNum, int g4Local_Buffer[]){
        AMediaWork aMediaWork = new AMediaWork();
        aMediaWork.FileQty = (g4Local_Buffer[1] & 0xffff);	// 1#文件总数
        aMediaWork.FileNumber = ((g4Local_Buffer[1] >> 16) & 0xffff);		// 1#当前播放文件编号
        aMediaWork.UserID = g4Local_Buffer[2];				// 2#用户ID
        aMediaWork.FileID = g4Local_Buffer[3];				// 3#文件ID
        aMediaWork.FileLength = g4Local_Buffer[4];			// 4#当前播放文件长度
        aMediaWork.SampleFreq = (g4Local_Buffer[5] & 0xffff);	// 5#当前播放文件取样频率
        aMediaWork.StreamRate = ((g4Local_Buffer[5] >> 16) & 0xffff);	// 5#当前播放文件码流率
        aMediaWork.TimeLength = (g4Local_Buffer[6] & 0xffff);		// 6#当前播放总时间
        aMediaWork.MediaType = ((g4Local_Buffer[6] >> 16) & 0xff);		// 6#当前播放文件格式

        aMediaWork.SongNameStr = cjmkcs.systemGetWpapperString(wpDEVICE_RegSongName | (regNum << 14) | devNum);
        g4EventMethod |= 0x00040000;
        return aMediaWork;
    }
    public AAmplifyWork eventAmplifyWork(int devNum, int event, int g4Local_Buffer[]){
        AAmplifyWork aAmplifyWork = new AAmplifyWork();
        aAmplifyWork.VolumeMax = (g4Local_Buffer[1] & 0xff);			// 1#总音量最大值
        aAmplifyWork.SpeakerConfig = ((g4Local_Buffer[1] >> 8) & 0xff);	// 1#大小扬声器设置
        aAmplifyWork.ToneBass = ((g4Local_Buffer[1] >> 16) & 0xffff);	// 1#音调低音及最大
        aAmplifyWork.ToneMid = (g4Local_Buffer[2] & 0xffff);			// 2#音调中音及最大
        aAmplifyWork.ToneTreble = ((g4Local_Buffer[2] >> 16) & 0xffff);	// 2#音调高音及最大
        aAmplifyWork.SyncDelay = (g4Local_Buffer[3] & 0xffff);		// 3#同时调节所有延时及最大
        aAmplifyWork.WooferFreq = ((g4Local_Buffer[3] >> 16) & 0xffff);	// 3#超低音频率及最大
        aAmplifyWork.FrontLeft = g4Local_Buffer[4];					// 4#前置左声道 微调/最大/延时/最大
        aAmplifyWork.FrontRight = g4Local_Buffer[5];					// 5#前置右声道 微调/最大/延时/最大
        aAmplifyWork.FrontCenter = g4Local_Buffer[6];					// 6#前中置声道 微调/最大/延时/最大
        aAmplifyWork.SubWoofer = g4Local_Buffer[7];					// 7#超低音声道 微调/最大/延时/最大
        aAmplifyWork.SurroundLeft = g4Local_Buffer[8];				// 8#环绕左声道 微调/最大/延时/最大
        aAmplifyWork.SurroundRight = g4Local_Buffer[9];				// 9#环绕右声道 微调/最大/延时/最大
        aAmplifyWork.BackLeft = g4Local_Buffer[10];					// 10#后置左声道 微调/最大/延时/最大
        aAmplifyWork.BackRight = g4Local_Buffer[11];					// 11#后置右声音 微调/最大/延时/最大
        g4EventMethod |= 0x00080000;
        return aAmplifyWork;
    }
    public int ReadRegister(int devNum, int event, int out_data[], int regType){
        int regNum = cjmkcs.systemClearEvent(tDEVICE, event, (2 << 16) | (regType << 8) | (devNum & 0xff));	// 读取寄存器所在的编号及清除相应的事件
        if (regNum >= 0){
            int g4Local_1 = wpDEVICE_Register | (regNum << 14) | (devNum & 0xff);		// [B15-B14]寄存器编号位于[B12-B8]计数器[B7-B0]devNum
            out_data[0] = cjmkcs.systemGetWpapperValue(g4Local_1 | 0);		// "wfRegist.h" REG_SYS
            int g4Local_2 = (out_data[0] >> 24) & 0x1f;
            int g4Local_3 = 1;
            do {
                out_data[g4Local_3] = cjmkcs.systemGetWpapperValue(g4Local_1 | (g4Local_3 << 8));
            } while (++g4Local_3 < g4Local_2);
        }
        return regNum;
    }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    public void getDevInfoDetail(int type, int number, ADeviceInfo aDeviceInfo[]){
        String gsLocal_1 = cjmkcs.systemGetWpapperString(type);
        aDeviceInfo[number] = new ADeviceInfo();
//System.out.println("getDevInfoDetail");System.out.println(aDeviceInfo);
        aDeviceInfo[number].DebugPort = cjmkcs.systemGetWpapperString(wpDEVICE_DebugPort);
        aDeviceInfo[number].MacAddress = cjmkcs.systemGetWpapperString(wpDEVICE_MacAddress);
        aDeviceInfo[number].IPAddress  = cjmkcs.systemGetWpapperString(wpDEVICE_IPAddress);
        aDeviceInfo[number].NetMask    = cjmkcs.systemGetWpapperString(wpDEVICE_NetMask);
        aDeviceInfo[number].GateWay    = cjmkcs.systemGetWpapperString(wpDEVICE_GateWay);
        aDeviceInfo[number].DnsServer  = cjmkcs.systemGetWpapperString(wpDEVICE_DnsServer);
        aDeviceInfo[number].isDhcpOn   = cjmkcs.systemGetWpapperValue(wpDEVICE_DhcpOn)>0 ? true:false;
        aDeviceInfo[number].isGenerateWifi   = cjmkcs.systemGetWpapperValue(wpDEVICE_GenerateWifi)>0 ? true:false;
        aDeviceInfo[number].DomainName  = cjmkcs.systemGetWpapperString(wpDEVICE_DomainName);
        aDeviceInfo[number].DomainPsw  = cjmkcs.systemGetWpapperString(wpDEVICE_DomainPsw);

        aDeviceInfo[number].ProductType = cjmkcs.systemGetWpapperValue(wpDEVICE_ProductType);
        aDeviceInfo[number].ProductSub = cjmkcs.systemGetWpapperValue(wpDEVICE_ProductSub);
        aDeviceInfo[number].ProductTypeStr = cjmkcs.systemGetWpapperString(wpDEVICE_ProductType);
        aDeviceInfo[number].ProductSubStr  = cjmkcs.systemGetWpapperString(wpDEVICE_ProductSub);

        aDeviceInfo[number].ProductBrand  = cjmkcs.systemGetWpapperString(wpDEVICE_ProductBrand);
        aDeviceInfo[number].ProductModel  = cjmkcs.systemGetWpapperString(wpDEVICE_ProductModel);
        aDeviceInfo[number].NickName  = cjmkcs.systemGetWpapperString(wpDEVICE_NickName);
        aDeviceInfo[number].GenWifiName   = cjmkcs.systemGetWpapperString(wpDEVICE_GenWifiName);
        aDeviceInfo[number].isDbsExist   = cjmkcs.systemGetWpapperValue(wpDEVICE_DbsExist)>0 ? true:false;
    }

    public void counterRunPercent(ARdWrFileStatus aRdWrFileStatus){
//        aRdWrFileStatus.RunPercent = MAPI_COUNTING_PERCENT(aRdWrFileStatus.Counter, aRdWrFileStatus.Length);
//        DWORD g4Local_1 = GetTickCount() - aRdWrFileStatus.RuningTick;
//        if (g4Local_1 < 1000){
//            aRdWrFileStatus.RuningTime.Format(L"%d毫秒", g4Local_1);
//        }
//        else {
//            aRdWrFileStatus.RuningTime.Format(L"%d.%d秒", g4Local_1/1000, g4Local_1%1000);
//        }
    }
    private static void MSTRING(String text) {
        Log.d("MSYS", text);
    }


}
